Repository navigation
feat(baidu-netdisk): refresh and rotate single-use tokens - #1156
Conversation
Xuanwo
left a comment
There was a problem hiding this comment.
AI-generated maintenance review of ff846503.
Baidu consumes the current refresh_token on exchange. RefreshCredentialProvider keeps the replacement in private memory, so even after a successful refresh and a clean shutdown, the host has no token it can use for the next refresh. Baidu OAuth documentation · OpenDAL persistence contract
Could you expose a Baidu-specific exchange that accepts the current refresh token and returns the replacement, together with the access token and expiry when usable? The host can then persist the replacement and rebuild its OpenDAL operator with the new access token. If Baidu returns a valid replacement alongside a missing or unusable access_token or expires_in, the result or error still needs to give the host that replacement. The old token has already been spent.
The in-process provider can keep automatic renewal if it hands every rotation back to the host, through a return value or a required callback. Please document that callers must serialize exchanges for each authorization and may need to reauthorize if the response is lost before the replacement is saved.
Xuanwo
left a comment
There was a problem hiding this comment.
AI-generated maintenance review of 269c8a5d.
The seven native tests and the WASM test in reqsign-baidu-netdisk never call RefreshCredentialProvider. A change that drops the replacement refresh token could pass all eight tests. Previous review
Could you add mock-response tests through the public exchange API? On success, have the caller save the replacement, recreate its state, and use the saved token for the next exchange. Also check that the caller receives the replacement when the same response contains an unusable access_token or expires_in. Baidu has already consumed the old refresh token in both cases.
|
Addressed both reviews in 5600440. The host can now call The public API tests exercise a second exchange after reloading the saved token from disk, and verify that a missing or invalid access token or expiry still yields the replacement. A provider test covers a failed save followed by a retry without a second HTTP exchange. These cases passed with mock responses. |
Xuanwo
left a comment
There was a problem hiding this comment.
AI-generated maintenance review of d4b48c9f.
The latest commit removes the three tests that exercised refresh-token rotation. Production code is unchanged. Running cargo test --offline -p reqsign-baidu-netdisk --no-fail-fast still passes all seven native tests, but none calls the refresh API. Baidu consumes the old token on exchange, so losing its replacement can force the caller to reauthorize.
Could you restore the tests from 5600440a or keep equivalent offline assertions through the public API before merge?
- The host can save the replacement, reload it after restart, and use it for the next exchange.
- The host receives the replacement even when the access token or expiry is unusable.
- After a save fails, a provider clone retries saving the same replacement before attempting another exchange.
This reverts commit d4b48c9.
Add Baidu Netdisk refresh-token exchange to Reqsign. A host calls
exchange_refresh_token, saves the replacement refresh token, then checksresponse.credentialfor the access token and its expiry. Even if the access token or expiry is unusable, the host receives the replacement.For on-demand renewal with
Signer,RefreshCredentialProvidertakes a required save callback. Provider clones serialize exchanges and saves. A failed save leaves the replacement pending so the next call retries persistence before exchanging another token. Hosts must serialize use of each authorization across processes. Losing the response before saving the replacement can require reauthorization.Verification
uinforequest returned HTTP 200 witherrno = 0.